<!--{*
/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2008 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
*}-->
<script type="text/javascript">
<!--
// リストボックスのサイズ変更
function ChangeSize(button, TextArea, Max, Min, row_tmp){
  if(TextArea.rows <= Min){
    TextArea.rows=Max; button.value="小さくする"; row_tmp.value=Max;
  }else{
    TextArea.rows =Min; button.value="大きくする"; row_tmp.value=Min;
  }
}

// SQL確認画面起動
function doPreview(){
  document.form1.mode.value="preview"
  document.form1.target = "_blank";
  document.form1.submit();
}

// formのターゲットを自分に戻す
function fnTargetSelf(){
  document.form1.target = "_self";
}

//-->
</script>


<form name="form1" id="form1" method="post" action="?">
<input type="hidden" name="mode" value="confirm" />
<input type="hidden" name="sql_id" value="<!--{$sql_id}-->" />
<input type="hidden" name="csv_output_id" value="" />
<input type="hidden" name="selectTable" value="" />
<div id="admin-contents" class="contents-main">
  <h2>SQL一覧</h2>

  <!--{if $arrSqlList}-->
  <table id="contents-csv-sqllist" class="list center">
    <!--{ foreach key=key item=item from=$arrSqlList }-->
    <tr style="background-color:<!--{if $item.sql_id == $sql_id}--><!--{$smarty.const.SELECT_RGB}--><!--{else}-->#ffffff<!--{/if}-->;">
      <td>
        <a href="<!--{$smarty.server.PHP_SELF|escape}-->?sql_id=<!--{$item.sql_id}-->" ><!--{$item.sql_name}--></a>
      </td>
      <td>
        <div class="btn">
          <button type='button' name='csv' onclick="fnTargetSelf(); fnFormModeSubmit('form1','csv_output','csv_output_id',<!--{$item.sql_id}-->);"><span>CSV出力</span></button>
          <button type='button' name='del' onclick="fnTargetSelf(); fnFormModeSubmit('form1','delete','sql_id',<!--{$item.sql_id}-->);"><span>削除</span></button>
        </div>
      </td>
    </tr>
    <!--{ /foreach }-->
  </table>
  <!--{/if}-->

  <div class="btn addnew">
    <button type='button' name='subm' onclick="fnTargetSelf(); fnFormModeSubmit('form1','new_page','','');"><span>SQLを新規入力</span></button>
  </div>


  <h2>SQL設定</h2>
  <table id="contents-csv-sqlset" class="form">
    <tr>
      <th>名称<span class="attention"> *</span></th>
      <td>
        <span class="attention"><!--{$arrErr.sql_name}--></span>
        <input type="text" name="sql_name" value="<!--{$arrSqlData.sql_name|escape}-->" maxlength="<!--{$smarty.const.STEXT_LEN}-->" style="<!--{if $arrErr.name != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->" size="60" class="box60" />
        <span class="attention"> （上限<!--{$smarty.const.STEXT_LEN}-->文字）</span>
      </td>
    </tr>
    <tr>
      <th align="center">SQL文<br />（SELECTは記述しないでください。）<span class="attention"> *</span></td>
      <td align="left">
        <span class="attention"><!--{$arrErr.csv_sql}--></span>
        <div>
          <textarea name="csv_sql" cols=75 rows=30 align="left" wrap=off style="<!--{if $arrErr.csv_sql != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->"><!--{$arrSqlData.csv_sql}--></textarea>
        </div>
      </td>
    </tr>
  </table>

  <div class="btn">
    <button type="submit" name="subm" onClick="mode.value='confirm'; fnTargetSelf();"><span>この内容で登録する</span></button>
    <button type="submit" name="subm" onClick="doPreview(); return false;"><span>構文エラーを確認する</span></button>
  </div>


  <div id="contents-csv-sqltbl">
    <h3>テーブル一覧</h3>
    <select name="arrTableList[]" size="20" style="width:325px; height:300px;" onChange="mode.value=''; selectTable.value=this.value; submit();" onDblClick="csv_sql.value = csv_sql.value +' , ' + this.value;">
      <!--{html_options options=$arrTableList selected=$selectTable}-->
    </select>
  </div>
  <div id="contents-csv-sqlcol">
    <h3>項目一覧</h3>
    <select name="arrColList[]" size="20" style="width:325px; height:300px;" onDblClick="csv_sql.value = csv_sql.value +' , ' + this.value;">
      <!--{html_options options=$arrColList}-->
    </select>
  </div>

</div>
</form>


</script>
